package com.yanqu.road.server.cmd.activity.dunhuangshiku;

import com.yanqu.road.entity.player.UserBaseInfo;
import com.yanqu.road.logic.pb.PlayerBasePb;
import com.yanqu.road.server.cmd.CrossUnionCommand;
import com.yanqu.road.utils.YanQuMessageUtils;
import com.yanqu.road.pb.dunhuangshiku.DunHuangShiKuProto;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.logic.MessageHelper;
import com.yanqu.road.server.manager.cross.battle.dunhuangshiku.DunHuangShiKuMgr;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.CrossProtocol;
import com.yanqu.road.server.protocol.GameProtocol;

import java.util.List;

/**
 * @Author cwq
 * @Date 2021/04/20
 */

@Cmd(code = CrossProtocol.C2_DUN_HUANG_SHI_KU_GET_USER_DATA, desc = "获取敦煌石窟用户数据")
public class CrossDunHuangShiKuGetUserDataCmd extends CrossUnionCommand {

    int activityId;
    long userId;
    UserBaseInfo userBaseInfo;
    long earnSpeed;
    long attack;
    long blood;
    boolean isEnter;
    List<DunHuangShiKuProto.DunHuangShiKuUserMallInfo> mallInfoList;

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        DunHuangShiKuProto.DunHuangShiKuGetUserDataCrossReqMsg msg = DunHuangShiKuProto.DunHuangShiKuGetUserDataCrossReqMsg.parseFrom(packet.getBytes());
        activityId = msg.getActivityId();
        userId = packet.getPlayerId();
        userBaseInfo = PlayerBasePb.parseToUserBaseInfo(msg.getPlayerInfo());
        earnSpeed = msg.getEarnSpeed();
        attack = msg.getAttack();
        blood = msg.getBlood();
        isEnter = msg.getIsEnter();
        mallInfoList = msg.getMallInfoListList();
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {
        DunHuangShiKuProto.DunHuangShiKuGetUserDataRespMsg.Builder builder = DunHuangShiKuMgr.getDunHuangShiKuUserMsg(activityId, userId,userBaseInfo,earnSpeed,attack,blood,isEnter,mallInfoList);
        MessageHelper.sendPacket(serverId, userId, YanQuMessageUtils.buildMessage(GameProtocol.S_DUN_HUANG_SHI_KU_GET_USER_DATA_FROM_CROSS, builder));
    }

    @Override
    public void sendData() {

    }
}
